﻿// Polygon.as 该类为多边线绘制
//vesion 1.0
//author 夏天的树人
package org.summerTree.graphics
{
	import flash.geom.Point;
	public class Polygon extends Base
	{
		//private var LineColor:uint=0x000000;//默认是黑色
		public function Polygon()
		{
			//this.graphics.moveTo(0,0);
		}
		
		override public function clone():*
		{
			return new Polygon();
		}
			
		//半径和次数
		/*radius 半径
		 *n  边数
		 *fillColor 填充颜色
		 *alpha 透明度填充透明度		
		*/
		public function CreatPolygon(radius:Number,n:int,fillColor:uint=0xffffff,alpha:Number=1):void
		{
			this.graphics.lineStyle(1,color);
			var angle:Number=2 * Math.PI / n;
			var tempArray:Array=new Array();
			for (var i:int=0; i < n; i++)
			{
				var px:Number=radius * Math.cos(i * angle);
				var py:Number=radius * Math.sin(i * angle);
				var point:Point=new Point(px,py);
				tempArray.push(point);
			}
			var len:int=tempArray.length;
			this.graphics.beginFill(fillColor,alpha);
			this.graphics.moveTo(tempArray[0].x,tempArray[0].y);
			for (var j:int=1; j < len; j++)
			{ 
				drawPoint(tempArray[j]);
			}
			this.graphics.lineTo(tempArray[0].x,tempArray[0].y);
			this.graphics.endFill();
            
		}
		//绘制线程序
		private function drawPoint(point:Point):void
		{
			this.graphics.lineTo(point.x,point.y);
		}
		//设置颜色
		//public function set color(value:uint):void
//		{
//			this.LineColor=value;
//		}
//		//获取颜色
//		public function get color():uint
//		{
//			return this.LineColor;
//		}
		////清除图像
//		public function clear():void
//		{
//			this.graphics.clear();
//		}
	}
}